<style lang="scss" scoped>
.remark {
  color: rgb(37, 137, 255);
  cursor: pointer;
  text-decoration: underline;
  font-weight: bold;
  margin: 17px 0;
}
.el-checkbox ::v-deep .el-checkbox__label {
  font-size: 16px;
  line-height: 2;
}
.el-checkbox ::v-deep .el-checkbox__inner {
  width: 15px;
  height: 15px;
  // margin-bottom: 5px;
}
</style>

<template>
  <el-form :model="form" ref="form" size="large">
    <!-- <el-row :inline="true"> -->
    <el-form-item label="自动审核" prop="autoApprove" style="margin: 15px 0">
      <el-checkbox true-label="0" false-label="1" v-model="form.autoApprove">
        自动审核
      </el-checkbox>
      <span
        style="
          color: rgb(37, 137, 255);
          cursor: pointer;
          text-decoration: underline;
          font-weight: bold;
          margin-left: 10px;
          font-size: 16px;
        "
        >说明：设置后将不经过审核，直接分货，库存分配</span
      >
    </el-form-item>
    <el-form-item label="自动通知" prop="isNotified">
      <el-checkbox true-label="0" false-label="1" v-model="form.isNotified">
        自动通知
      </el-checkbox>
      <span
        style="
          color: rgb(37, 137, 255);
          cursor: pointer;
          text-decoration: underline;
          font-weight: bold;
          margin-left: 10px;
          font-size: 16px;
        "
        >说明：设置后，将直接推送分货通知到相关负责人钉钉</span
      >
      <el-button
        style="margin-left: 5px"
        type="primary"
        plain
        size="mini"
        @click="handleDingding"
        >钉钉设置</el-button
      >
    </el-form-item>
    <el-dialog :visible.sync="openInfo" width="1800px">
      <BiWarehouseDingdingBinding />
    </el-dialog>
    <!-- </el-row> -->
    <el-form-item style="width: 100%; text-align: center">
      <!-- <el-button @click="submitnote('noticForm')" type="primary"
        >笔记合作</el-button
      > -->
      <el-button style="margin-top: 12px" @click="prev">上一步</el-button>
      <el-button style="margin-top: 12px" @click="submitForm">完成</el-button>
      <!-- <el-button @click="resetForm" style="margin-left: 10px"
        >一键清空</el-button
      > -->
    </el-form-item>
  </el-form>
</template>
<script>
import {
  listStrategy,
  getStrategy,
  delStrategy,
  addStrategy,
  updateStrategy,
} from "@/api/productAllocation/strategy";
import BiWarehouseDingdingBinding from "@/views/productAllocation/BiWarehouseDingdingBinding/index.vue";
export default {
  props: {
    row: {
      type: Object,
      default: () => {},
    },
  },
  components: {
    BiWarehouseDingdingBinding,
  },
  data() {
    return {
      openInfo: false,
      // 表单参数
      form: {},
    };
  },
  watch: {
    row: {
      handler: function (newnew, oldold) {
        console.log("newnew", newnew);
        if (newnew) {
          this.form = newnew;
          // this.form.id=newnew
        }
      },
      deep: true,
      immediate: true,
    },
  },
  methods: {
    handleDingding() {
      this.openInfo = true;
    },
    prev() {
      this.$emit("prev");
    },
    next() {
      this.$emit("next");
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != null) {
            updateStrategy(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              // this.$router.push({
              //   path: "/productAllocation/futures/strategy",
              // });
              // this.open = false;
              // this.getList();
            });
          } else {
            addStrategy(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              // this.open = false;
              // this.getList();
            });
          }
        }
      });
    },
  },
};
</script>